﻿using System;
using System.Collections.Generic;
using BalanceManager.Model;
using BalanceManager.Services;
using BalanceManager.ViewModels;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

namespace UnitTests.ViewModelTests
{
    [TestClass]
    public class MainViewModelTests
    {
        private MainViewModel mainViewModel;
        private DateTime startDate;
        private DateTime endDate;

        [TestInitialize]
        public void Init()
        {
            var now = DateTime.Now;
            startDate = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
            endDate = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59);
            var dataServiceMock = new Mock<IDataService>();
            dataServiceMock.Setup(s => s.LoadFundFlows(startDate, endDate)).Returns(GetTestFundFlowList());
            mainViewModel = new MainViewModel(dataServiceMock.Object);
        }

        [TestMethod]
        public void LoadFundFlowsafterItsActivation()
        {
            mainViewModel.Activate(null);
            Assert.AreEqual(1, mainViewModel.FundFlows.Count);
        }

        private List<FundFlow> GetTestFundFlowList()
        {
            var list = new List<FundFlow>();
            list.Add(new FundFlow(FlowType.Expense) { Id = 1, Amount = 10, ItemId = 1, ItemName = "Test1"});
            
            return list;
        }
    }
}
